1 <?php
2 // This script and data application were generated by AppGini 5.62
3 // Download AppGini for free from https://bigprof.com/appgini/download/
4
5 $currDir=dirname(__FILE__);
6 include("$currDir/defaultLang.php");
7 include("$currDir/language.php");
8 include("$currDir/lib.php");
9 @include("$currDir/hooks/medical_records.php");
10 include("$currDir/medical_records_dml.php");
11
12 // mm: can the current member access this page?
13 $perm=getTablePermissions('medical_records');
14 if(!$perm[0]){
15 echo error_message($Translation['tableAccessDenied'], false);
16 echo '<script>setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
17 exit;
18 }
19
20 $x = new DataList;
21 $x->TableName = "medical_records";
22
23 // Fields that can be displayed in the table view
24 $x->QueryFieldsTV = array(
25 "`medical_records`.`id`" => "id",
26 "IF( CHAR_LENGTH(`patients1`.`last_name`) || CHAR_LENGTH(`patients1`.`first_name`), CONCAT_WS('', `patients1`.`last_name`, ',', `patients1`.`first_name`), '') /* Patient */" => "patient",
27 "`medical_records`.`image_1`" => "image_1",
28 "`medical_records`.`image_2`" => "image_2",
29 "`medical_records`.`image_3`" => "image_3",
30 "`medical_records`.`image_4`" => "image_4",
31 "`medical_records`.`image_5`" => "image_5",
32 "`medical_records`.`document_1`" => "document_1",
33 "`medical_records`.`document_2`" => "document_2",
34 "`medical_records`.`document_3`" => "document_3",
35 "`medical_records`.`document_4`" => "document_4",
36 "`medical_records`.`document_5`" => "document_5",
37 "`medical_records`.`description`" => "description"
38 );
39 // mapping incoming sort by requests to actual query fields
40 $x->SortFields = array(
41 1 => '`medical_records`.`id`',
42 2 => 2,
43 3 => 3,
44 4 => 4,
45 5 => 5,
46 6 => 6,
47 7 => 7,
48 8 => 8,
49 9 => 9,
50 10 => 10,
51 11 => 11,
52 12 => 12,
53 13 => 13
54 );
55
56 // Fields that can be displayed in the csv file
57 $x->QueryFieldsCSV = array(
58 "`medical_records`.`id`" => "id",
59 "IF( CHAR_LENGTH(`patients1`.`last_name`) || CHAR_LENGTH(`patients1`.`first_name`), CONCAT_WS('', `patients1`.`last_name`, ',', `patients1`.`first_name`), '') /* Patient */" => "patient",
60 "`medical_records`.`image_1`" => "image_1",
61 "`medical_records`.`image_2`" => "image_2",
62 "`medical_records`.`image_3`" => "image_3",
63 "`medical_records`.`image_4`" => "image_4",
64 "`medical_records`.`image_5`" => "image_5",
65 "`medical_records`.`document_1`" => "document_1",
66 "`medical_records`.`document_2`" => "document_2",
67 "`medical_records`.`document_3`" => "document_3",
68 "`medical_records`.`document_4`" => "document_4",
69 "`medical_records`.`document_5`" => "document_5",
70 "`medical_records`.`description`" => "description"
71 );
72 // Fields that can be filtered
73 $x->QueryFieldsFilters = array(
74 "`medical_records`.`id`" => "ID",
75 "IF( CHAR_LENGTH(`patients1`.`last_name`) || CHAR_LENGTH(`patients1`.`first_name`), CONCAT_WS('', `patients1`.`last_name`, ',', `patients1`.`first_name`), '') /* Patient */" => "Patient",
76 "`medical_records`.`document_1`" => "Document 1",
77 "`medical_records`.`document_2`" => "Document 2",
78 "`medical_records`.`document_3`" => "Document 3",
79 "`medical_records`.`document_4`" => "Document 4",
80 "`medical_records`.`document_5`" => "Document 5",
81 "`medical_records`.`description`" => "Description"
82 );
83
84 // Fields that can be quick searched
85 $x->QueryFieldsQS = array(
86 "`medical_records`.`id`" => "id",
87 "IF( CHAR_LENGTH(`patients1`.`last_name`) || CHAR_LENGTH(`patients1`.`first_name`), CONCAT_WS('', `patients1`.`last_name`, ',', `patients1`.`first_name`), '') /* Patient */" => "patient",
88 "`medical_records`.`document_1`" => "document_1",
89 "`medical_records`.`document_2`" => "document_2",
90 "`medical_records`.`document_3`" => "document_3",
91 "`medical_records`.`document_4`" => "document_4",
92 "`medical_records`.`document_5`" => "document_5",
93 "`medical_records`.`description`" => "description"
94 );
95
96 // Lookup fields that can be used as filterers
97 $x->filterers = array( 'patient' => 'Patient');
98
99 $x->QueryFrom = "`medical_records` LEFT JOIN `patients` as patients1 ON `patients1`.`id`=`medical_records`.`patient` ";
100 $x->QueryWhere = '';
101 $x->QueryOrder = '';
102
103 $x->AllowSelection = 1;
104 $x->HideTableView = ($perm[2]==0 ? 1 : 0);
105 $x->AllowDelete = $perm[4];
106 $x->AllowMassDelete = false;
107 $x->AllowInsert = $perm[1];
108 $x->AllowUpdate = $perm[3];
109 $x->SeparateDV = 1;
110 $x->AllowDeleteOfParents = 0;
111 $x->AllowFilters = 1;
112 $x->AllowSavingFilters = 0;
113 $x->AllowSorting = 1;
114 $x->AllowNavigation = 1;
115 $x->AllowPrinting = 1;
116 $x->AllowCSV = 1;
117 $x->RecordsPerPage = 10;
118 $x->QuickSearch = 1;
119 $x->QuickSearchText = $Translation["quick search"];
120 $x->ScriptFileName = "medical_records_view.php";
121 $x->RedirectAfterInsert = "medical_records_view.php?SelectedID=#ID#";
122 $x->TableTitle = "Medical Records";
123 $x->TableIcon = "resources/table_icons/cash_terminal.png";
124 $x->PrimaryKey = "`medical_records`.`id`";
125
126 $x->ColWidth = array( 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150);
127 $x->ColCaption = array("Patient", "Image 1", "Image 2", "Image 3", "Image 4", "Image 5", "Document 1", "Document 2", "Document 3", "Document 4", "Document 5", "Description");
128 $x->ColFieldName = array('patient', 'image_1', 'image_2', 'image_3', 'image_4', 'image_5', 'document_1', 'document_2', 'document_3', 'document_4', 'document_5', 'description');
129 $x->ColNumber = array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
130
131 // template paths below are based on the app main directory
132 $x->Template = 'templates/medical_records_templateTV.html';
133 $x->SelectedTemplate = 'templates/medical_records_templateTVS.html';
134 $x->TemplateDV = 'templates/medical_records_templateDV.html';
135 $x->TemplateDVP = 'templates/medical_records_templateDVP.html';
136
137 $x->ShowTableHeader = 1;
138 $x->ShowRecordSlots = 0;
139 $x->TVClasses = "";
140 $x->DVClasses = "";
141 $x->HighlightColor = '#FFF0C2';
142
143 // mm: build the query based on current member's permissions
144 $DisplayRecords = $_REQUEST['DisplayRecords'];
145 if(!in_array($DisplayRecords, array('user', 'group'))){ $DisplayRecords = 'all'; }
146 if($perm[2]==1 || ($perm[2]>1 && $DisplayRecords=='user' && !$_REQUEST['NoFilter_x'])){ // view owner only
147 $x->QueryFrom.=', membership_userrecords';
148 $x->QueryWhere="where `medical_records`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='medical_records' and lcase(membership_userrecords.memberID)='".getLoggedMemberID()."'";
149 }elseif($perm[2]==2 || ($perm[2]>2 && $DisplayRecords=='group' && !$_REQUEST['NoFilter_x'])){ // view group only
150 $x->QueryFrom.=', membership_userrecords';
151 $x->QueryWhere="where `medical_records`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='medical_records' and membership_userrecords.groupID='".getLoggedGroupID()."'";
152 }elseif($perm[2]==3){ // view all
153 // no further action
154 }elseif($perm[2]==0){ // view none
155 $x->QueryFields = array("Not enough permissions" => "NEP");
156 $x->QueryFrom = '`medical_records`';
157 $x->QueryWhere = '';
158 $x->DefaultSortField = '';
159 }
160 // hook: medical_records_init
161 $render=TRUE;
162 if(function_exists('medical_records_init')){
163 $args=array();
164 $render=medical_records_init($x, getMemberInfo(), $args);
165 }
166
167 if($render) $x->Render();
168
169 // hook: medical_records_header
170 $headerCode='';
171 if(function_exists('medical_records_header')){
172 $args=array();
173 $headerCode=medical_records_header($x->ContentType, getMemberInfo(), $args);
174 }
175 if(!$headerCode){
176 include_once("$currDir/header.php");
177 }else{
178 ob_start(); include_once("$currDir/header.php"); $dHeader=ob_get_contents(); ob_end_clean();
179 echo str_replace('<%%HEADER%%>', $dHeader, $headerCode);
180 }
181
182 echo $x->HTML;
183 // hook: medical_records_footer
184 $footerCode='';
185 if(function_exists('medical_records_footer')){
186 $args=array();
187 $footerCode=medical_records_footer($x->ContentType, getMemberInfo(), $args);
188 }
189 if(!$footerCode){
190 include_once("$currDir/footer.php");
191 }else{
192 ob_start(); include_once("$currDir/footer.php"); $dFooter=ob_get_contents(); ob_end_clean();
193 echo str_replace('<%%FOOTER%%>', $dFooter, $footerCode);
194 }
195 ?>